package top.llove.scheduled;

import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 定时任务类
 * @author: 幸会
 * @date: 2021/6/6 16:27
 * @email: 1846724873@qq.com
 * @description: LogScheduled
 * version: 1.0
 */
@Component
@Slf4j
@Async("getAsync")
public class LogScheduled {
    //@Scheduled(cron = "20 40 16 * * ?") // 每天下午4点40分 20秒执行
    // cron语法：秒 分 时 日 月 周 年(可省略)
//    @Scheduled(initialDelay = 3000, fixedRate = 1000)
    public void test() {
        long before = System.currentTimeMillis();
        System.out.println(IdUtil.simpleUUID());
        long after = System.currentTimeMillis();
        System.out.println("一耗费：" + (after - before));
    }

//    @Scheduled(initialDelay = 2000, fixedRate = 1000)
    public void test2() {
        long before = System.currentTimeMillis();
        System.out.println(IdUtil.fastSimpleUUID());
        long after = System.currentTimeMillis();
        System.out.println("二耗费：" + (after - before));
    }
}
